package cc.rboot.inject.aspect;

import cc.rboot.inject.helper.InjectSetterHelper;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class InjectSetterAspect {

    @Pointcut("@annotation(cc.rboot.inject.annotation.InjectSetter)")
    public void pointCut() {
    }

    @Around("pointCut()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        Object[] params = joinPoint.getArgs();
        for (Object param : params) {
            InjectSetterHelper.injectSetter(param);
        }
        return joinPoint.proceed();
    }
}
